/**
*
*/
#include <set>
#include <unordered_set>
#include <iostream>
#include <string>

using namespace std;

class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        if (s.size() == 0) { return 0; }
        unordered_set<char> lookup;
        int maxStr = 0;
        int start = 0;
        for (int end = 0; end < s.size(); end++) {
            while (lookup.find(s[end]) != lookup.end()) {
                lookup.erase(s[start]);
                start++;
            }
            maxStr = max(maxStr, end - start + 1);
            lookup.insert(s[end]);
        }
        return maxStr;

    }
};


int main() {
    string str = "abcabcbb";
    Solution s;
    std::cout << s.lengthOfLongestSubstring(str);
}